package schronisko;

import java.sql.*;
//import java.sql.Connection;

public class MySQLConnection {
	private final static String DBURL = "jdbc:mysql://localhost:3306/schronisko";
    private final static String DBUSER = "root";
    private final static String DBPASS = "";
    private final static String DBDRIVER = "com.mysql.jdbc.Driver";
    
    private static Connection conn;
    private static Statement st;
    
    public static Statement connect() {
    	try {
			Class.forName(DBDRIVER).newInstance();
			conn = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
			st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
		    
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.err.println("Problem z polaczeniem z baza" + e);
		}
    	return st;
    }
    public static void Close() {
    	try {
			st.close();
			conn.close();
		} catch (SQLException e) {
			System.err.println("Problem z zamknieciem bazy");
		}  
    }
}
